import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
  SaleItemForecastQuery,
  SaleItemForecastPageResult,
  SaleItemForecastFormVO,
} from "./types";

/**
 * 分页列表
 *
 * @param queryParams
 */
export function getPage(
  queryParams: SaleItemForecastQuery
): AxiosPromise<SaleItemForecastPageResult> {
  return request({
    url: "/api/v1/saleitemforecast/page",
    method: "get",
    params: queryParams,
  });
}

/**
 * 表单数据
 *
 * @param id
 */
export function getForm(id: number): AxiosPromise<SaleItemForecastFormVO> {
  return request({
    url: "/api/v1/saleitemforecast/" + id + "/form",
    method: "get",
  });
}

/**
 * 新增
 *
 * @param data
 */
export function add(data: SaleItemForecastFormVO) {
  return request({
    url: "/api/v1/saleitemforecast",
    method: "post",
    data: data,
  });
}

/**
 * 修改
 *
 * @param id
 * @param data
 */
export function update(id: number, data: SaleItemForecastFormVO) {
  return request({
    url: "/api/v1/saleitemforecast/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除
 */
export function deletes(ids: string) {
  return request({
    url: "/api/v1/saleitemforecast/" + ids,
    method: "delete",
  });
}

/**
 * 获取字典类型的数据项
 *
 * @param typeCode 字典类型编码
 */
export function getSaleCustomerOptions(
  typeCode: string
): AxiosPromise<OptionType[]> {
  return request({
    url: "/api/v1/salecustomer/options",
    method: "get",
  });
}
